package com.xieyong.mywebsite.mapper;

import com.xieyong.mywebsite.model.entity.Blog;
import org.apache.ibatis.annotations.*;
import org.junit.platform.commons.annotation.Testable;

import java.util.Date;
import java.util.List;

@Mapper

public interface BlogMapper {

    @Select("SELECT id,img,title,content,create_time,create_id from blog where is_deleted = 0 and id = #{id}")
    Blog selectBlogById(Integer id);

    @Select("SELECT id,img,title,content,create_time,create_id from blog where is_deleted = 0")
    List<Blog> selectAllBlog();

    List<Blog> selectBlogByCondition(Integer createId, String title, String content, Date startTime, Date endTime);

    @Insert("INSERT into blog (id,img,title,content,create_time,create_id) value (#{id},#{img},#{title},#{content},#{createTime},#{createId})")
    void insertBlog(Blog blog);

    @Update("UPDATE blog set img = #{img},title = #{title},content = #{content} where id = #{id}")
    void updateBlog(Blog blog);

    @Delete("UPDATE blog set is_deleted = 1, deleted_time = #{deletedtime}, deleted_id = #{deletedid} where id = #{id}")
    void deleteBlog(Date deletedtime, Integer deletedid, Integer id);
}
